package com.zhongfl.crm.model.boss;

import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Optional;

/**
 * 工单相关人
 *
 * @author wang.yuchuan
 * @date 2018/5/21
 */
@Getter
@Setter
public class WorkOrderStaffs extends OrderStaffs {

    /**
     * 当前登录用户
     */
    private String currentStaffCode;

    /**
     * 分配人
     */
    private AmibaStaff assigneeStaff;

    /**
     * 受理人
     */
    private AmibaStaff claimStaff;

    /**
     * 受理部门的阿米巴巴长
     */
    private List<AmibaStaff> receiveAmibaManagers;

    /**
     * 是否允许重新发起结算或修改结算
     */
    private Boolean isReceiveAmibaManager;

    public Boolean getIsReceiveAmibaManager() {
        if (CollectionUtils.isEmpty(getReceiveAmibaManagers())) {
            return false;
        }
        if (StringUtils.isEmpty(currentStaffCode)) {
            return false;
        }
        Optional<AmibaStaff> optional = receiveAmibaManagers.stream()
            .filter(m -> m.getStaffCode().equals(currentStaffCode))
            .findAny();
        return optional.isPresent();
    }
}
